package com.easy;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Lxk on 2019/6/8.
 */

class Node {
    public int val;
    public List<Node> children;

    public Node() {}

    public Node(int _val,List<Node> _children) {
        val = _val;
        children = _children;
    }
};
public class Solution589 {


    private void preVisit(Node root,List<Integer> res){
        if(root==null){
            return ;
        }
        res.add(root.val);
        for(Node node : root.children){
            preVisit(node,res);
        }
    }

    public List<Integer> preorder(Node root) {
        List<Integer> res = new ArrayList<>();
        preVisit(root,res);
        return res;
    }


}
